package cn.com.nes.site.service.workOrder.impl;

import cn.com.nes.common.util.OssImagePathUtils;
import cn.com.nes.mybatis.callcenter.mapper.WorkOrderRepairPicMapper;
import cn.com.nes.site.service.workOrder.WorkOrderRepairPicService;
import cn.com.nes.site.service.workOrder.dto.WorkOrderRepairPicDTO;
import cn.hutool.core.collection.CollectionUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * 维修工单图片服务
 *
 * @Author: ShenWei
 * @Date: 2024/05/28/13:20
 */
@Service
public class WorkOrderRepairPicServiceImpl implements WorkOrderRepairPicService {

    @Resource
    private WorkOrderRepairPicMapper workOrderRepairPicMapper;

    @Override
    public List<WorkOrderRepairPicDTO> getPicList(Long workOrderId) {
        List<WorkOrderRepairPicDTO> picList = workOrderRepairPicMapper.getPicList(workOrderId);
        if (CollectionUtil.isNotEmpty(picList)) {
            picList.forEach(item -> {
                String url = OssImagePathUtils.getImgSignURL(item.getPath(), 2, "https://oss-cn-beijing.aliyuncs.com", "LTAI4GGGPjJdh83sy2vf2Hx3", "LsuL7otABT1a6eIXdhH7dOWcqGeqos", "nescallcenter");
                item.setUrl(url);
            });
        }
        return picList;
    }
}
